package store.lunangangster.bpmn.converter.parser;

import javax.xml.stream.XMLStreamReader;
import org.apache.commons.lang3.StringUtils;
import store.lunangangster.bpmn.model.BaseElement;
import store.lunangangster.bpmn.model.BpmnModel;

/**
 * 用于documentation子元素的解析
 *
 * @author cwk
 * @version 1.0
 */
public class DocumentationParser extends BaseChildElementParser {

  /**
   * 从xml输入流中解析出父元素中存在的子元素，根据不同的实现方式解析不同的子元素
   * @param xsr           xml文件输入流
   * @param parentElement 父元素
   * @throws Exception    输入流异常
   */
  @Override
  public void parseChild(XMLStreamReader xsr, BaseElement parentElement, BpmnModel model) throws Exception {
    String documentation = xsr.getElementText();
    if (StringUtils.isNotBlank(documentation)) {
      parentElement.setDocumentation(documentation.trim());
    }
  }

  @Override
  public String getTargetName() {
    return ELEMENT_DOCUMENTATION;
  }
}
